home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmllib21.zoo / csin.c.orig < prev    next >
Encoding:
Text File  |  1992-04-01  |  4.0 KB  |  191 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20. /*
  21.  *  FUNCTION
  22.  *
  23.  *    csin   complex double precision sine
  24.  *
  25.  *  KEY WORDS
  26.  *
  27.  *    csin
  28.  *    complex functions
  29.  *    machine independent routines
  30.  *    math libraries
  31.  *
  32.  *  DESCRIPTION
  33.  *
  34.  *    Computes double precision complex sine of a double
  35.  *    precision complex argument.
  36.  *
  37.  *  USAGE
  38.  *
  39.  *    COMPLEX csin (z)
  40.  *    COMPLEX z;
  41.  *
  42.  *  REFERENCES
  43.  *
  44.  *    Fortran 77 user's guide, Digital Equipment Corp. pp B-12
  45.  *
  46.  *  PROGRAMMER
  47.  *
  48.  *    Fred Fish
  49.  *    Tempe, Az 85281
  50.  *    (602) 966-8871
  51.  *
  52.  *  INTERNALS
  53.  *
  54.  *    Computes complex sine of z = x + j y from:
  55.  *
  56.  *        1.    r_csin = sin(x) * cosh(y)
  57.  *
  58.  *        2.    i_csin = cos(x) * sinh(y)
  59.  *
  60.  *        3.    csin(z) = r_csin + j i_csin
  61.  *
  62.  */
  63.  
  64. #if !defined (__M68881__) && !defined (sfp004)
  65.  
  66. #include <stdio.h>
  67. #include <math.h>
  68. #include "pml.h"
  69.  
  70. COMPLEX csin (z)
  71. COMPLEX z;
  72. {
  73.     COMPLEX result;
  74.  
  75.     result.real = sin (z.real) * cosh (z.imag);
  76.     result.imag = cos (z.real) * sinh (z.imag);
  77.     return (result);
  78. }
  79. #endif !defined (__M68881__) && !defined (sfp004)
  80.  
  81. #ifdef    __M68881__
  82. __asm("
  83. .text
  84. _funcname:
  85.     .ascii    \"csin\\0\"
  86.     .even
  87.     .globl _csin
  88. _csin:
  89.     movel    a1,d0        | save a1 as return value
  90.     fmoved    sp@(4),fp0    | z.real
  91.     fcosx    fp0,fp1        | cos(z.real)
  92.     fsinx    fp0,fp0        | sin(z.real)
  93.  
  94.     fmoved    sp@(12),fp3    | z.imag
  95.     fcoshx    fp3,fp2        | cosh(z.imag)
  96.     fsinhx    fp3,fp3        | sinh(z.imag)
  97.     
  98.     fmulx    fp2,fp0        | result.real
  99.     fmoved    fp0,a1@        |
  100.     fmulx    fp3,fp1        | result.imag
  101.     fmoved    fp1,a1@(8)    |
  102. ");    /* end asm    */
  103. #endif    __M68881__
  104.  
  105. #ifdef    sfp004
  106. __asm("
  107. | double precision floating point stuff for Atari-gcc using the SFP004
  108. | developed with gas
  109. |
  110. | double precision complex sin
  111. |
  112. | M. Ritzert (mjr at dmzrzu71)
  113. |
  114. | 12.10.1990
  115. |
  116. | addresses of the 68881 data port. This choice is fastest when much data is
  117. | transferred between the two processors.
  118.  
  119. comm =     -6
  120. resp =    -16
  121. zahl =      0
  122.  
  123. | waiting loop ...
  124. |
  125. | wait:
  126. | ww:    cmpiw    #0x8900,a1@(resp)
  127. |     beq    ww
  128. | is coded directly by
  129. |    .long    0x0c688900, 0xfff067f8
  130. | and
  131. | www:    tst.b    a1@(resp)
  132. |    bmi.b    www
  133. | is coded by
  134. |    .word    0x4a68,0xfff0,0x6bfa        | test
  135.  
  136.     .text; .even
  137.     .globl _csin
  138. _csin:
  139.     movel    a1,d0                | save a1 as return value
  140.     lea    0xfffa50,a0            | fpu address
  141.  
  142.     movew    #0x5431,a0@(comm)        | sincos: sin -> fp0 
  143.     .long    0x0c688900, 0xfff067f8        |      cos -> fp1
  144.     movel    sp@(4), a0@            | load z.real
  145.     movel    sp@(8), a0@            | load z.real
  146.  
  147. |    fmoved    sp@(12),fp3            | z.imag to fp3
  148.     movew    #0x5580,a0@(comm)
  149.     .long    0x0c688900, 0xfff067f8
  150.     movel    sp@(12),a0@
  151.     movel    sp@(16),a0@
  152.  
  153. |    fcoshx    fp3,fp2                | cosh(z.imag)
  154.     movew    #0x0d19,a0@(comm)
  155.     .word    0x4a68,0xfff0,0x6bfa        | test
  156. |    fsinhx    fp3,fp3                | sinh(z.imag)
  157.     movew    #0x0d82,a0@(comm)
  158.     .word    0x4a68,0xfff0,0x6bfa        | test
  159. |    fmulx    fp2,fp0                | result.real
  160.     movew    #0x0823,a0@(comm)
  161.     .word    0x4a68,0xfff0,0x6bfa        | test
  162. |    fmoved    fp0,a1@                |
  163.     movew    #0x7400,a0@(comm)        | 
  164.     .long    0x0c688900, 0xfff067f8
  165.     movel    a0@,a1@
  166.     movel    a0@,a1@(4)
  167. |    fmulx    fp3,fp1                | result.imag
  168.     movew    #0x0ca3,a0@(comm)
  169.     .word    0x4a68,0xfff0,0x6bfa        | test
  170. |    fmoves    fp1,d1                |
  171.     movew    #0x7480,a0@(comm)        |
  172.     .long    0x0c688900, 0xfff067f8
  173.     movel    a0@,a1@(8)
  174.     movel    a0@,a1@(12)
  175. ");    /* end asm    */
  176. #endif    sfp004
  177.  
  178.  
  179. #if defined (__M68881__) || defined (sfp004)
  180. # ifdef ERROR_CHECK    /* no error checking for now    */
  181. __asm("
  182.     pea    _funcname
  183.     jmp    c_err_check
  184. ");    /* end asm    */
  185. # else  ERROR_CHECK
  186.  
  187. __asm("rts");
  188.  
  189. # endif ERROR_CHECK
  190. #endif defined (__M68881__) || defined (sfp004)
  191.